import unittest
import nnreport
import  os,sys
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
from config.conf import CASE_PATH, REPORT_PATH
sys.path.insert(0,ROOT_PATH)

def run(case_expr, report_title, report_name):
    suite = unittest.defaultTestLoader.discover(CASE_PATH, case_expr)
    report = nnreport.BeautifulReport(suite)
    report.report(report_title, report_name, log_path=REPORT_PATH)
    error=report.error_count
    success=report.success_count
    #没有写如何报告
    report_content="""
    hi all:
        本次自动化测试执行已完成，共执行了%s条case，成功%s条，失败%s条，详细信息见report:
        http://xxxxx
        report.html
    """%(success+error,success,error)
    #nginx===>html
    #todo 给一个nginx的配置
    #server
    #listen 80;
    #server_name xxx

if __name__ == '__main__':
    run("Test*", "通过运行程序执行自动化case", "utp-report.html")
